<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLessonTestsTable extends Migration
{

    protected $tableName = 'lesson_tests';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('名称');
            $table->string('description')->comment('描述');
            $table->unsignedInteger('template_id')->comment('模版ID');
            $table->json('content')->comment('测试内容');
            $table->unsignedInteger('lesson_id')->comment('关联课时ID');
            $table->integer('level_id')->comment('级别ID');
            $table->unsignedTinyInteger('sequence')->comment('测试排序');
            $table->timestamps();

            $table->softDeletes();

            $table->index(['lesson_id', 'level_id'], 'lesson_level');
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '课时测试'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
